<#include "/includes/vars.inc">  
<@pp.dropOutputFile />
<#list entities.entity as entity>
    <@pp.changeOutputFile name="${webDir}/jeecode/"+entity.@name?uncap_first+"/include/"+entity.@name?cap_first+"List.xhtml" />
    <#assign entityName = entity.@name>
   	<#--<@pp.setOutputEncoding encoding="UTF-8"/>-->
    <#assign managedBean = entity.@name?uncap_first+"Controller">
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition> 
    	<p:commandButton value="${r"#{"}msg.create${r"}"} ${r"#{"}msg.${entityName?uncap_first}${r"}"}"
                                     title="${r"#{"}msg.create${r"}"} ${r"#{"}msg.${entityName?uncap_first}${r"}"}"
                                     oncomplete="${entityName}CreateDialog.show()"
                                     actionListener="${r"#{"}${managedBean}${r".prepareCreate}"}"
                                     update="<#if entity.@parent[0]??>:tab${entity.@parent}</#if>:form${entityName}Create:data"
                                     icon="ui-icon ui-icon-plus"
                                     style="margin-bottom: 10px;">   
        </p:commandButton>
        <h:panelGroup id="data">
            <p:dataTable        
                value="${r"#{"}${managedBean}${r".items}"}"
                var="current"
                styleClass="apm-dataTable"
                paginator="true"
                paginatorPosition="bottom"
                rows="10">
                <f:facet name="header">           				
                </f:facet>
                <p:column style="width:120px;text-align: center">
                    <p:commandButton ajax="false"
                                 icon="ui-icon ui-icon-search"
                                 action="/jeecode/${entityName?uncap_first}/${entityName}View.jsf"
                                 title="${r"#{"}msg.view${r"}"} ${r"#{"}msg.${entityName?uncap_first}${r"}"}">
                        <f:setPropertyActionListener value="${r"#{"}current${r"}"}" target="${r"#{"}${managedBean}${r".current}"}" />  
                    </p:commandButton>
                    <p:spacer width="5" />
                    <p:commandButton update="<#if entity.@parent[0]??>:tab${entity.@parent}</#if>:form${entityName}Edit:data" 
                                     title="${r"#{"}msg.edit${r"}"} ${r"#{"}msg.${entityName?uncap_first}${r"}"}"
                                     icon="ui-icon ui-icon-pencil"
                                     oncomplete="${entityName}EditDialog.show()">  
                        <f:setPropertyActionListener value="${r"#{"}current${r"}"}" target="${r"#{"}${managedBean}${r".current}"}" />  
                    </p:commandButton>
                    <p:spacer width="5" />
                    <#if !entity.column.@name?seq_contains("baja") >
                    <p:commandButton oncomplete="confirm${entityName}Dialog.show()"
                                     title="${r"#{"}msg.delete${r"}"} ${r"#{"}msg.${entityName?uncap_first}${r"}"}"
                                     icon="ui-icon ui-icon-close">  
                        <f:setPropertyActionListener value="${r"#{"}current${r"}"}" target="${r"#{"}${managedBean}${r".current}"}" />  
                    </p:commandButton> 
                    </#if>
                </p:column>
                <#list entity.column as column>
                    <#if column.@primary="false">
                        <#if !enums.enum.@name?seq_contains(column.@type)>
                <p:column style="text-align: center" sortBy="${r"#{"}current.${column.@name}${r"}"}" <#if !(column.@type ="Date") && !(column.@type ="Boolean") >filterBy="${r"#{"}current.${column.@name}${r"}"}"  filterMatchMode="contains" </#if>  headerText="${r"#{"}msg.${entityName?uncap_first}${column.@name?cap_first}${r"}"}">
                        <#else>
                <p:column style="text-align: center" sortBy="${r"#{"}current.${column.@name}${r"}"}" filterBy="${r"#{"}current.${column.@name}${r"}"}" filterOptions="${r"#{"}utilController.${column.@type?uncap_first}Items}" headerText="${r"#{"}msg.${entityName?uncap_first}${column.@name?cap_first}${r"}"}">
                        </#if>
                        <#if column.@type = "Date" >
                    <h:outputText value="${r"#{"}current.${column.@name}${r"}"}">
                        <f:convertDateTime pattern="${config.date.@pattern}" timeZone="${r"#{"}utilController.timeZone}" />
                    </h:outputText>
                   		<#elseif (column.@type ="Integer") || (column.@type ="Double") || (column.@type ="Float")>
                   			<#if column.@numType="CURRENCY">
                    <h:outputText value="${r"#{"}current.${column.@name}${r"}"}">
                        <f:convertNumber type="currency" maxFractionDigits="2" />
                    </h:outputText>
                    		<#elseif column.@numType="PERCENT">
                    <h:outputText value="${r"#{"}current.${column.@name}${r"}"}%" />
                    		<#else>
                    <h:outputText value="${r"#{"}current.${column.@name}${r"}"}">
                        <f:convertNumber type="number" minFractionDigits="0" maxFractionDigits="2" />
                    </h:outputText>
                    		</#if>
                        <#elseif column.@type = "Boolean">
                    <h:selectBooleanCheckbox disabled="true" value="${r"#{"}current.${column.@name}${r"}"}" />
                        <#else>
                    <h:outputText value="${r"#{"}current.${column.@name}${r"}"}"/>
                        </#if>                
                </p:column>
                    </#if>
                </#list>
                <f:facet name="footer">
                  
                   <p:commandButton update="<#if entity.@parent[0]??>:tab${entity.@parent}</#if>:form${entityName}List:data"
                                    icon="ui-icon ui-icon-refresh"
                                    actionListener="${r"#{"}${managedBean}${r".refreshItems}"}"
                                    value="${r"#{"}msg.update${r"}"}"
                                    />
                </f:facet>
            </p:dataTable>
        </h:panelGroup>
    </ui:composition>

</html>

</#list>